import { stringify } from 'qs';
import request from '@/utils/request';

//查询
export async function searchFormIf (params) {
  let url = '/iot/dmp/v1/roles/list'
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

export async function findPlatform () {
  let url = '/iot/dmp/v1/common/types/PLATFORM_TYPE/base-list'
  return request(url);
}

//新增
export async function addForm (params) {
  let url = '/iot/dmp/v1/roles/create'
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  });
}
//编辑
export async function updateRole (params) {
  let url = `/iot/dmp/v1/roles/${params.role_id}`
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  });
}
//删除
export async function deleteReq (params) {

  let url = `/iot/dmp/v1/roles/delete/${params.role_id}`
  return request(url, {
    method: 'GET',
  });
}

//设置权限
export async function editForm (params) {

  let url = `/iot/dmp/v1/permissions/update`
  //console.log(JSON.stringify(params));
  return request(url, {
    method: 'POST',
    body: {
      ...params
    }
  });
}

//查询权限树
export async function searchTree (params) {
  console.log(params)
  let url = '/iot/dmp/v1/permissions/tree'
  return request(url, {
    method: 'POST',
    body: {
      ...params
    }
  });
}
//查询权限树
export async function searchPermisstionList (params) {
  //console.log(params)
  let url = `/iot/dmp/v1/permissions/list`
  return request(url, {
    method: 'POST',
    body: {
      ...params
    }
  });
}

//权限详情查询
export async function detailsSearch (params) {
  let url = `/iot/dmp/v1/roles/${params.role_id}`;
  return request(url, {
    method: 'GET',
  });
}
//查询“所属租户”的选项
export async function findAll (params) {

  let url = `/iot/dmp/v1/tenants/alllist`
  return request(url, {
    method: 'POST'}
  );
}
